package com.xiaocikuai.smallchunks.mapper.Card;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaocikuai.smallchunks.entity.Card.CardChunks;
import com.xiaocikuai.smallchunks.entity.Transaction.VirtualOrder;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.Set;


public interface CardChunksMapper extends BaseMapper<CardChunks> {
    @Insert("INSERT INTO card_chunks (cid, word_id, front, back, back_hl, front_hl, product_id, create_time, update_time, sort) " +
            "VALUES (#{cid}, #{wordId}, #{front}, #{back}, #{backHl}, #{frontHl}, #{productId}, #{createTime}, #{updateTime}, #{sort})")
    boolean insertCardChunk(CardChunks cardChunk);


    @Insert("INSERT INTO yshop_virtual_order (uid, pid, use_type, status, create_time, ifdis) " +
            "VALUES (#{uid}, #{pid}, #{useType}, #{status}, #{createTime}, #{ifdis})")
    boolean insertCardChunk1(VirtualOrder virtualOrder);

    @Insert("INSERT INTO collection (cid, uid, time) " +
            "VALUES (#{cid}, #{uid}, #{time})")
    boolean collectionAdd(int cid, long uid, LocalDateTime time);

    @Delete("DELETE FROM collection WHERE cid = #{cid} AND uid = #{uid}")
    boolean collectionDel(int cid, long uid);

    @Select("SELECT COUNT(*) FROM collection WHERE cid = #{cid} AND uid = #{uid}")
    int isCollect(int cid, long uid);


    @Select("SELECT * FROM card_chunks WHERE cid = #{cid} ")
    CardChunks getCardById(int cid);

    @Select("select cid from collection where uid = #{uid} ")
    Set<Integer> collectList(Integer uid);

    @Select("SELECT * FROM card_chunks WHERE cid = #{cid} and product_id = #{pid} ")
    CardChunks getCardCollect(int cid ,int pid);




}
